class strp:
    global l, result, i

    def issametype(self, i):
        try:
            int(l[i][-1])
            try:
                int(l[i + 1][0])
                return True
            except:
                return False
        except:
            try:
                int(l[i + 1][0])
                return False
            except:
                return True

    def isobverse(self, i):
        return True if l[i][-1] < l[i + 1][0] else False

    def issame(self, i):
        return True if l[i][-1] == l[i + 1][0] else False

    def insert_rule(self):
        global i, result
        l_temp = []
        Ord = ord(l[i][-1])
        Ord += 1
        while Ord != ord(l[i + 1][0]):
            l_temp.append(chr(Ord))
            Ord += 1
        if z == "2":
            l_temp.reverse()
        else:
            pass

        if x == "2":
            for m in range(len(l_temp)):
                temp = l_temp[m]
                if 97 <= ord(temp) <= (97 + 25):
                    l_temp[m] = chr(ord(temp) - 32)
        elif x == "3":
            l_temp = ["*" * len(l_temp)]
        else:
            pass
        for m in l_temp:
            result += m * int(y)

    def p(self):
        global result, i
        for i in range(len(l) - 1):
            result += l[i]
            if self.issametype(i):
                if self.isobverse(i):
                    self.insert_rule()

                elif self.issame(i):
                    result += "-"

                else:
                    result += "-"

            else:
                result += "-"


v = input().split("\n")
x, y, z = v[0].split()
l = v[1].split("-")
o = strp()
result = ""
o.p()
result += l[-1]
print(result)
